import {BasicColumn} from '/@/components/Table';
import {FormSchema} from '/@/components/Table';
import { rules} from '/@/utils/helper/validator';
import { render } from '/@/utils/common/renderUtils';
//列表数据
export const columns: BasicColumn[] = [
  {
    title: '目录id',
    align: "center",
    dataIndex: 'id'
  },
  {
    title: '有声书ID',
    align: "center",
    dataIndex: 'bookId'
  },
  {
    title: '目录号',
    align: "center",
    dataIndex: 'indexNum'
  },
  {
    title: '目录名',
    align: "center",
    dataIndex: 'indexName'
  },
  {
    title: '音频时长',
    align: "center",
    dataIndex: 'audioDuration'
  },
  {
    title: '是否收费',
    align: "center",
    dataIndex: 'isVip',
    customRender:({text}) => {
      return  text?'是':'否'
    },
  },
  {
    title: '分集费用',
    align: "center",
    dataIndex: 'indexPrice'
  },
  {
    title: '更新时间',
    align: "center",
    dataIndex: 'updateTime'
  },
];
columns.forEach(item=>{
  item.resizable=true
})
//查询数据
export const searchFormSchema: FormSchema[] = [
  {
    label: "有声书ID",
    field: 'bookId',
    component: 'Input',
    colProps: {span: 6},
  },
];

//表单数据
export const formSchema: FormSchema[] = [
  {
    label: '有声书ID',
    field: 'bookId',
    component: 'InputNumber',
    dynamicRules: ({model,schema}) => {
      return [
              { required: true, message: '请输入有声书ID!'},
             ];
    },
  },
  {
    label: '目录号',
    field: 'indexNum',
    component: 'InputNumber',
    dynamicRules: ({model,schema}) => {
      return [
              { required: true, message: '请输入目录号!'},
             ];
    },
  },
  {
    label: '目录名',
    field: 'indexName',
    component: 'Input',
    dynamicRules: ({model,schema}) => {
      return [
              { required: true, message: '请输入目录名!'},
             ];
    },
  },
  {
    label: '是否收费',
    field: 'isVip',
    component: 'Input',
    dynamicRules: ({model,schema}) => {
      return [
              { required: true, message: '请输入是否收费!'},
             ];
    },
  },
  {
    label: '分集费用',
    field: 'indexPrice',
    component: 'InputNumber',
    dynamicRules: ({model,schema}) => {
      return [
              { required: true, message: '请输入分集费用!'},
             ];
    },
  },
	// TODO 主键隐藏字段，目前写死为ID
  {
    label: '',
    field: 'id',
    component: 'Input',
    show: false,
  },
];
